<template>
    <div class="update">
        <van-cell-group>
            <van-field v-model="oldpwd" placeholder="旧密码" :error-message="olderr == 1 ? '密码错误' : ''"/>
        </van-cell-group>
        <van-cell-group>
            <van-field v-model="newpwd" placeholder="新密码" :error-message="olderr == 1 ? '密码格式错误' : ''"/>
        </van-cell-group>
        <van-cell-group>
            <van-field v-model="repwd" placeholder="确认新密码" :error-message="reerr == 1 ? '密码不一致' : ''"/>
        </van-cell-group>
        <!-- btn -->
        <van-button type="warning" size="large" class="save" @click="toSave">确认并保存</van-button>
    </div>
</template>

<script>
import { Notify } from 'vant';
export default {
    data() {
        return {
            oldpwd: '',
            newpwd: '',
            repwd: '',
            olderr: 0,
            newerr: 0,
            reerr: 0
        }
    },
    methods: {
        toSave() {
            if (this.oldpwd.trim() == '' || this.newpwd.trim() == '' || this.repwd.trim() == '') {
                Notify({
                    message: '表单不能为空，请填写完整',
                    duration: 1000,
                    background: 'rgb(255, 68, 68)'
                })
                return
            }
            this.$router.push({path: '/user/userInfo'})
        }
    } 
}
</script>

<style lang="less" scoped>

</style>
